package me.numark.activities;

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.umeng.analytics.MobclickAgent;

import butterknife.Bind;
import butterknife.ButterKnife;
import me.numark.R;

/**
 * Created by Evan on 15/7/23.
 */
public class BaseActivity extends AppCompatActivity {

    protected int activity_layout_res;

    @Bind(R.id.toolbar)
    @Nullable
    Toolbar toolbar;

    @Bind(R.id.toolbar_title)
    @Nullable
    TextView titleTextView;

    @Bind(R.id.back)
    @Nullable
    View backInToolbar;

    View rootView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTheme(R.style.AppTheme);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        if (activity_layout_res != 0)
            setContentView(activity_layout_res);
        ButterKnife.bind(this);
        if (backInToolbar != null)
            backInToolbar.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onBackPressed();
                }
            });
        rootView = getWindow().getDecorView().findViewById(android.R.id.content);
    }

    public void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    public void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }

}
